package org.jeecgframework.web.system.pojo.base;

import net.lahuobao.finance.entity.reccode.ReccodeEntity;
import org.hibernate.annotations.Where;
import org.jeecgframework.core.common.entity.IdEntity;
import org.jeecgframework.poi.excel.annotation.Excel;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 部门机构表
 *
 * @author 张代浩
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "t_s_depart")
@Where(clause = "is_working = 1")
public class TSDepart extends IdEntity implements java.io.Serializable {
    private TSDepart TSPDepart;//上级部门
    @Excel(name = "组织机构名称")
    private String departname;//部门名称
    @Excel(name = "组织机构描述")
    private String description;//部门描述
    @Excel(name = "机构编码")
    private String orgCode;//机构编码
    //@Excel(name = "机构类型编码")
    private String orgType;//机构编码
    @Excel(name = "电话")
    private String mobile;//电话
    @Excel(name = "传真")
    private String fax;//传真
    @Excel(name = "地址")
    private String address;//地址
    //@Excel(name = "是否是服务商")
    private String carrier;    //服务商标识：1表示是服务商
    //@Excel(name = "是否是承运商")
    private String service;    //承运商标识：1表示是承运商
    //@Excel(name = "是否是数据主体")
    private String dataOwner;    //数据主体标识：1表示是数据主体
    //@Excel(name = "是否是垫付机构")
    private String advance;

    @Excel(name = "业务角色")
    private String businessoleName;

    private int working;                        //是否有效  0以删除 1未删除

    //2016-08-31 LiJie添加开始
    @Excel(name = "机构类型")
    private String exOrgType;                    //导出使用-组织机构类型

    private ReccodeEntity reccodeEntity;        //推荐码
    @Excel(name = "推荐码")
    private String exRecCode;                    //推荐码 导出使用

    @Excel(name = "营业执照号")
    private String businessLicense;            //营业执照号

    private String businessLicenseSrc;            //营业执照号码图片路径

    @Excel(name = "组织机构代码")
    private String organizational;                //组织机构代码

    private String organizationalSrc;            //组织机构代码图片路径

    @Excel(name = "法人身份证号")
    private String legalCard;                    //法人身份证号

    private String legalCardSrc;                //法人身份证图片路径
    //2016-08-31 Lijie添加结束
    //部门类型 1-门店 2-区域 0-部门
    private int departType;
    // 地区代码
    private String areaCode;
    //门店负责人
    private String zonePrincipal;
    //经纬度
    private String point;
    //是否400门店
    private boolean isHead;
    //备注
    private String remark;
    //状态 数据字典  0-禁用 1-启用
    private boolean isEnable;

    @Column(name = "depart_type")
    public int getDepartType() {
        return departType;
    }

    public void setDepartType(int departType) {
        this.departType = departType;
    }

    @Column(name = "area_code")
    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    @Column(name = "zone_principal")
    public String getZonePrincipal() {
        return zonePrincipal;
    }

    public void setZonePrincipal(String zonePrincipal) {
        this.zonePrincipal = zonePrincipal;
    }

    @Column(name = "point")
    public String getPoint() {
        return point;
    }

    public void setPoint(String point) {
        this.point = point;
    }

    @Column(name = "is_head")
    public boolean isHead() {
        return isHead;
    }

    public void setHead(boolean head) {
        isHead = head;
    }

    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Column(name = "is_enable")
    public boolean isEnable() {
        return isEnable;
    }

    public void setEnable(boolean enable) {
        isEnable = enable;
    }

    private List<TSDepart> TSDeparts = new ArrayList<TSDepart>();//下属部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parentdepartid")
    public TSDepart getTSPDepart() {
        return this.TSPDepart;
    }

    public void setTSPDepart(TSDepart TSPDepart) {
        this.TSPDepart = TSPDepart;
    }

    @Column(name = "departname", nullable = false, length = 100)
    public String getDepartname() {
        return this.departname;
    }

    public void setDepartname(String departname) {
        this.departname = departname;
    }

    @Column(name = "description", length = 500)
    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TSPDepart")
    public List<TSDepart> getTSDeparts() {
        return TSDeparts;
    }

    public void setTSDeparts(List<TSDepart> tSDeparts) {
        TSDeparts = tSDeparts;
    }

    @Column(name = "org_code", length = 64)
    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    @Column(name = "org_type", length = 1)
    public String getOrgType() {
        return orgType;
    }

    public void setOrgType(String orgType) {
        this.orgType = orgType;
        this.exOrgType = orgType;
    }

    @Column(name = "mobile", length = 32)
    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Column(name = "fax", length = 32)
    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    @Column(name = "address", length = 100)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "isCarrier")
    public String getCarrier() {
        return carrier;
    }

    public void setCarrier(String carrier) {
        this.carrier = carrier;
    }

    @Column(name = "isDataOwner")
    public String getDataOwner() {
        return dataOwner;
    }

    public void setDataOwner(String dataOwner) {
        this.dataOwner = dataOwner;
    }

    @Column(name = "isService")
    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    @Column(name = "isAdvance")
    public String getAdvance() {
        return advance;
    }

    public void setAdvance(String advance) {
        this.advance = advance;
    }

    @OneToOne(mappedBy = "tsDepart")
    public ReccodeEntity getReccodeEntity() {
        return reccodeEntity;
    }

    public void setReccodeEntity(ReccodeEntity reccodeEntity) {
        this.reccodeEntity = reccodeEntity;
        if (reccodeEntity != null) {
            this.exRecCode = reccodeEntity.getRecCode();
        }
    }

    @Transient
    public String getReccodeEntityecCode() {
        if (reccodeEntity != null) {
            return reccodeEntity.getRecCode();
        } else {
            return "";
        }
    }

    @Transient
    public String getBusinessoleName() {
        if (businessoleName == null) {
            businessoleName = "";
        }
        if (this.carrier != null && this.carrier.equals("1")) {
            businessoleName += "物流服务商";
        }
        if (this.service != null && this.service.equals("1")) {
            businessoleName += "乘运商";
            if (businessoleName.length() > 0) {
                businessoleName += ",";
            }
        }
        if (this.dataOwner != null && this.dataOwner.equals("1")) {
            businessoleName += "数据主体";
            if (businessoleName.length() > 0) {
                businessoleName += ",";
            }
        }
        if (this.advance != null && this.advance.equals("1")) {
            businessoleName += "垫付机构";
            if (businessoleName.length() > 0) {
                businessoleName += ",";
            }
        }
        return businessoleName;
    }

    public void setBusinessoleName(String businessoleName) {
        this.businessoleName = businessoleName;
    }

    @Column(name = "businessLicense")
    public String getBusinessLicense() {
        return businessLicense;
    }

    public void setBusinessLicense(String businessLicense) {
        this.businessLicense = businessLicense;
    }

    @Column(name = "businessLicense_src")
    public String getBusinessLicenseSrc() {
        return businessLicenseSrc;
    }

    public void setBusinessLicenseSrc(String businessLicenseSrc) {
        this.businessLicenseSrc = businessLicenseSrc;
    }

    @Column(name = "legal_card")
    public String getLegalCard() {
        return legalCard;
    }

    public void setLegalCard(String legalCard) {
        this.legalCard = legalCard;
    }

    @Column(name = "legal_card_src")
    public String getLegalCardSrc() {
        return legalCardSrc;
    }

    public void setLegalCardSrc(String legalCardSrc) {
        this.legalCardSrc = legalCardSrc;
    }

    @Column(name = "organizational")
    public String getOrganizational() {
        return organizational;
    }

    public void setOrganizational(String organizational) {
        this.organizational = organizational;
    }

    @Column(name = "organizational_src")
    public String getOrganizationalSrc() {
        return organizationalSrc;
    }

    public void setOrganizationalSrc(String organizationalSrc) {
        this.organizationalSrc = organizationalSrc;
    }

    @Column(name = "is_working")
    public int getWorking() {
        return working;
    }

    public void setWorking(int working) {
        this.working = working;
    }

    @Transient
    public String getExRecCode() {
        return exRecCode;
    }

    public void setExRecCode(String exRecCode) {
        this.exRecCode = exRecCode;
    }

    @Transient
    public String getExOrgType() {
        if (this.orgType == null) {
            return "";
        }
        if (this.orgType.equals("1")) {
            return "公司";
        }
        if (this.orgType.equals("2")) {
            return "组织机构";
        }
        if (this.orgType.equals("3")) {
            return "岗位";
        }
        return "";
    }

    public void setExOrgType(String exOrgType) {
        this.exOrgType = exOrgType;
    }
}